{ CNVTOMDL
  Converteert programmalijst naar include file formaat. Deze kan gebruikt
  worden voor MDLIST.EXE (wordt meegelinkt).

  Copyright (C) 1993, Marc Dorsman
}

program CNVTOMDL;

uses Dos;

var InFile, OutFile: text;
    IFile, OFile, DTA: string;
    TxtBuf: array [1..600] of string[90]; {array van 600 regels}
    Positie,I,N: integer;

begin
  N:=0;
  writeln;
  writeln ('CNVTOMDL   Version 1.0á   Copyright (C) 1993, Marc Dorsman');
  writeln ('Converts softwarelist to include file for use with MDLIST.');
  writeln;
  write ('Input file: ');
  readln (IFile);
  write ('Output file: ');
  readln (OFile);
  assign (InFile,IFile);
  reset (InFile);
  writeln ('Reading ',FExpand(IFile));
  repeat
    Inc (N,1);
    readln (InFile,DTA);
    Positie:=Pos('''',DTA);
    if Positie>0 then
      begin
        repeat
          Positie:=Pos('''',DTA);
          {insert('''',DTA,Pos('''',DTA));} {39 is ASCII code van ' }
          if Positie<>0 then
            begin
              delete (DTA,Positie,1);
              insert (#01+#01,DTA,Positie);
            end;
        until Positie=0;
      end;
    TxtBuf[N]:=DTA;
  until eof(InFile);
  close (InFile);
  for I:=1 to N do
     begin
       DTA:=TxtBuf[I];
       repeat
         Positie:=Pos(#01,DTA);
         if Positie<>0 then DTA[Positie]:=#39;
       until Positie=0;
       TxtBuf[I]:=DTA;
     end;
  assign (OutFile,OFile);
  rewrite (OutFile);
  writeln ('Writing file to ',FExpand(OFile));
  {for I:=1 to N do writeln (OutFile,TxtBuf[I]);}
  writeln (OutFile,'CONST');
  writeln (OutFile,'  ProgCount=',N,';');
  writeln (OutFile,'  ProgList: array [1..ProgCount] of string[90] = (');
  writeln (OutFile,''''+TxtBuf[1]+''',');
  for I:=2 to N-1 do writeln (OutFile,''''+TxtBuf[I]+''',');
  writeln (OutFile,''''+TxtBuf[N]+''');');


  close (OutFile);
end.